
#ifndef SINGLETON_H
#define SINGLETON_H

// INCLUDES ********************************************************************

#include "Logger.h"

// FORWARD DECLARATIONS ********************************************************

// *****************************************************************************

//! Singleton
//! 
//! To provide a common code base for the objects that are to have 1 instance
//! only, this class template provides basic Singleton functionality
//! Please note: thread-safety or destruction problems ( dead-reference etc.,
//! see 'Modern C++ Design') are not taken care of, due to simplicity

// *****************************************************************************

namespace Meteor 
{
    template <class T>
    class Singleton
    {
        public:
            static T& Instance();
        
        protected:
            Singleton(){};
        
        private:
            Singleton( const Singleton<T>& rhs);
            
            Singleton<T>& operator=( const Singleton<T>& rhs);
            
    }; // end of class template 'Singleton'
    
    template<class T>
    T& Instance();
    
} // end of namespace Meteor

#pragma mark -
#pragma mark Template functions
// -----------------------------------------------------------------------------

template<class T>
T& Meteor::Singleton<T>::Instance()
    {
        static T instance;
        
        return instance;
    }


#endif
